home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / game / shoot / ADoom_src_1_1.lha / ADoom_src / r_defs.h < prev    next >
C/C++ Source or Header  |  1998-02-20  |  9KB  |  493 lines

  1. // Emacs style mode select   -*- C++ -*- 
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // DESCRIPTION:
  18. //      Refresh/rendering module, shared data struct definitions.
  19. //
  20. //-----------------------------------------------------------------------------
  21.  
  22.  
  23. #ifndef __R_DEFS__
  24. #define __R_DEFS__
  25.  
  26.  
  27. // Screenwidth.
  28. #include "doomdef.h"
  29.  
  30. // Some more or less basic data types
  31. // we depend on.
  32. #include "m_fixed.h"
  33.  
  34. // We rely on the thinker data struct
  35. // to handle sound origins in sectors.
  36. #include "d_think.h"
  37. // SECTORS do store MObjs anyway.
  38. #include "p_mobj.h"
  39.  
  40.  
  41.  
  42. #ifdef __GNUG__
  43. #pragma interface
  44. #endif
  45.  
  46.  
  47.  
  48. // Silhouette, needed for clipping Segs (mainly)
  49. // and sprites representing things.
  50. #define SIL_NONE        0
  51. #define SIL_BOTTOM        1
  52. #define SIL_TOP            2
  53. #define SIL_BOTH        3
  54.  
  55. #define MAXDRAWSEGS        256
  56. //#define MAXDRAWSEGS        1024
  57.  
  58.  
  59.  
  60. //
  61. // INTERNAL MAP TYPES
  62. //  used by play and refresh
  63. //
  64.  
  65. //
  66. // Your plain vanilla vertex.
  67. // Note: transformed values not buffered locally,
  68. //  like some DOOM-alikes ("wt", "WebView") did.
  69. //
  70. typedef struct
  71. {
  72.     fixed_t    x;
  73.     fixed_t    y;
  74.     
  75. } vertex_t;
  76.  
  77.  
  78. // Forward of LineDefs, for Sectors.
  79. struct line_s;
  80.  
  81. // Each sector has a degenmobj_t in its center
  82. //  for sound origin purposes.
  83. // I suppose this does not handle sound from
  84. //  moving objects (doppler), because
  85. //  position is prolly just buffered, not
  86. //  updated.
  87. typedef struct
  88. {
  89.     thinker_t        thinker;    // not used for anything
  90.     fixed_t        x;
  91.     fixed_t        y;
  92.     fixed_t        z;
  93.  
  94. } degenmobj_t;
  95.  
  96. //
  97. // The SECTORS record, at runtime.
  98. // Stores things/mobjs.
  99. //
  100. typedef    struct
  101. {
  102.     fixed_t    floorheight;
  103.     fixed_t    ceilingheight;
  104.     short    floorpic;
  105.     short    ceilingpic;
  106.     short    lightlevel;
  107.     short    special;
  108.     short    tag;
  109.  
  110.     // 0 = untraversed, 1,2 = sndlines -1
  111.     int        soundtraversed;
  112.  
  113.     // thing that made a sound (or null)
  114.     mobj_t*    soundtarget;
  115.  
  116.     // mapblock bounding box for height changes
  117.     int        blockbox[4];
  118.  
  119.     // origin for any sounds played by the sector
  120.     degenmobj_t    soundorg;
  121.  
  122.     // if == validcount, already checked
  123.     int        validcount;
  124.  
  125.     // list of mobjs in sector
  126.     mobj_t*    thinglist;
  127.  
  128.     // thinker_t for reversable actions
  129.     void*    specialdata;
  130.  
  131.     int            linecount;
  132.     struct line_s**    lines;    // [linecount] size
  133.     
  134. } sector_t;
  135.  
  136.  
  137.  
  138.  
  139. //
  140. // The SideDef.
  141. //
  142.  
  143. typedef struct
  144. {
  145.     // add this to the calculated texture column
  146.     fixed_t    textureoffset;
  147.     
  148.     // add this to the calculated texture top
  149.     fixed_t    rowoffset;
  150.  
  151.     // Texture indices.
  152.     // We do not maintain names here. 
  153.     short    toptexture;
  154.     short    bottomtexture;
  155.     short    midtexture;
  156.  
  157.     // Sector the SideDef is facing.
  158.     sector_t*    sector;
  159.     
  160. } side_t;
  161.  
  162.  
  163.  
  164. //
  165. // Move clipping aid for LineDefs.
  166. //
  167. typedef enum
  168. {
  169.     ST_HORIZONTAL,
  170.     ST_VERTICAL,
  171.     ST_POSITIVE,
  172.     ST_NEGATIVE
  173.  
  174. } slopetype_t;
  175.  
  176.  
  177.  
  178. typedef struct line_s
  179. {
  180.     // Vertices, from v1 to v2.
  181.     vertex_t*    v1;
  182.     vertex_t*    v2;
  183.  
  184.     // Precalculated v2 - v1 for side checking.
  185.     fixed_t    dx;
  186.     fixed_t    dy;
  187.  
  188.     // Animation related.
  189.     short    flags;
  190.     short    special;
  191.     short    tag;
  192.  
  193.     // Visual appearance: SideDefs.
  194.     //  sidenum[1] will be -1 if one sided
  195.     short    sidenum[2];            
  196.  
  197.     // Neat. Another bounding box, for the extent
  198.     //  of the LineDef.
  199.     fixed_t    bbox[4];
  200.  
  201.     // To aid move clipping.
  202.     slopetype_t    slopetype;
  203.  
  204.     // Front and back sector.
  205.     // Note: redundant? Can be retrieved from SideDefs.
  206.     sector_t*    frontsector;
  207.     sector_t*    backsector;
  208.  
  209.     // if == validcount, already checked
  210.     int        validcount;
  211.  
  212.     // thinker_t for reversable actions
  213.     void*    specialdata;        
  214. } line_t;
  215.  
  216.  
  217.  
  218.  
  219. //
  220. // A SubSector.
  221. // References a Sector.
  222. // Basically, this is a list of LineSegs,
  223. //  indicating the visible walls that define
  224. //  (all or some) sides of a convex BSP leaf.
  225. //
  226. typedef struct subsector_s
  227. {
  228.     sector_t*    sector;
  229.     short    numlines;
  230.     short    firstline;
  231.     
  232. } subsector_t;
  233.  
  234.  
  235.  
  236. //
  237. // The LineSeg.
  238. //
  239. typedef struct
  240. {
  241.     vertex_t*    v1;
  242.     vertex_t*    v2;
  243.     
  244.     fixed_t    offset;
  245.  
  246.     angle_t    angle;
  247.  
  248.     side_t*    sidedef;
  249.     line_t*    linedef;
  250.  
  251.     // Sector references.
  252.     // Could be retrieved from linedef, too.
  253.     // backsector is NULL for one sided lines
  254.     sector_t*    frontsector;
  255.     sector_t*    backsector;
  256.     
  257. } seg_t;
  258.  
  259.  
  260.  
  261. //
  262. // BSP node.
  263. //
  264. typedef struct
  265. {
  266.     // Partition line.
  267.     fixed_t    x;
  268.     fixed_t    y;
  269.     fixed_t    dx;
  270.     fixed_t    dy;
  271.  
  272.     // Bounding box for each child.
  273.     fixed_t    bbox[2][4];
  274.  
  275.     // If NF_SUBSECTOR its a subsector.
  276.     unsigned short children[2];
  277.     
  278. } node_t;
  279.  
  280.  
  281.  
  282.  
  283. // posts are runs of non masked source pixels
  284. typedef struct
  285. {
  286.     byte        topdelta;    // -1 is the last post in a column
  287.     byte        length;     // length data bytes follows
  288. } post_t;
  289.  
  290. // column_t is a list of 0 or more post_t, (byte)-1 terminated
  291. typedef post_t    column_t;
  292.  
  293.  
  294.  
  295. // PC direct to screen pointers
  296. //B UNUSED - keep till detailshift in r_draw.c resolved
  297. //extern byte*    destview;
  298. //extern byte*    destscreen;
  299.  
  300.  
  301.  
  302.  
  303.  
  304. //
  305. // OTHER TYPES
  306. //
  307.  
  308. // This could be wider for >8 bit display.
  309. // Indeed, true color support is posibble
  310. //  precalculating 24bpp lightmap/colormap LUT.
  311. //  from darkening PLAYPAL to all black.
  312. // Could even us emore than 32 levels.
  313. typedef byte    lighttable_t;    
  314.  
  315.  
  316.  
  317.  
  318. //
  319. // ?
  320. //
  321. typedef struct drawseg_s
  322. {
  323.     seg_t*        curline;
  324.     int            x1;
  325.     int            x2;
  326.  
  327.     fixed_t        scale1;
  328.     fixed_t        scale2;
  329.     fixed_t        scalestep;
  330.  
  331.     // 0=none, 1=bottom, 2=top, 3=both
  332.     int            silhouette;
  333.  
  334.     // do not clip sprites above this
  335.     fixed_t        bsilheight;
  336.  
  337.     // do not clip sprites below this
  338.     fixed_t        tsilheight;
  339.     
  340.     // Pointers to lists for sprite clipping,
  341.     //  all three adjusted so [x1] is first value.
  342.     short*        sprtopclip;        
  343.     short*        sprbottomclip;    
  344.     short*        maskedtexturecol;
  345.     
  346. } drawseg_t;
  347.  
  348.  
  349.  
  350. // Patches.
  351. // A patch holds one or more columns.
  352. // Patches are used for sprites and all masked pictures,
  353. // and we compose textures from the TEXTURE1/2 lists
  354. // of patches.
  355. typedef struct 
  356.     short        width;        // bounding box size 
  357.     short        height; 
  358.     short        leftoffset;    // pixels to the left of origin 
  359.     short        topoffset;    // pixels below the origin 
  360.     int            columnofs[8];    // only [width] used
  361.     // the [0] is &columnofs[width] 
  362. } patch_t;
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370. // A vissprite_t is a thing
  371. //  that will be drawn during a refresh.
  372. // I.e. a sprite object that is partly visible.
  373. typedef struct vissprite_s
  374. {
  375.     // Doubly linked list.
  376.     struct vissprite_s*    prev;
  377.     struct vissprite_s*    next;
  378.     
  379.     int            x1;
  380.     int            x2;
  381.  
  382.     // for line side calculation
  383.     fixed_t        gx;
  384.     fixed_t        gy;        
  385.  
  386.     // global bottom / top for silhouette clipping
  387.     fixed_t        gz;
  388.     fixed_t        gzt;
  389.  
  390.     // horizontal position of x1
  391.     fixed_t        startfrac;
  392.     
  393.     fixed_t        scale;
  394.     
  395.     // negative if flipped
  396.     fixed_t        xiscale;    
  397.  
  398.     fixed_t        texturemid;
  399.     int            patch;
  400.  
  401.     // for color translation and shadow draw,
  402.     //  maxbright frames as well
  403.     lighttable_t*    colormap;
  404.    
  405.     int            mobjflags;
  406.     
  407. } vissprite_t;
  408.  
  409.  
  410. //    
  411. // Sprites are patches with a special naming convention
  412. //  so they can be recognized by R_InitSprites.
  413. // The base name is NNNNFx or NNNNFxFx, with
  414. //  x indicating the rotation, x = 0, 1-7.
  415. // The sprite and frame specified by a thing_t
  416. //  is range checked at run time.
  417. // A sprite is a patch_t that is assumed to represent
  418. //  a three dimensional object and may have multiple
  419. //  rotations pre drawn.
  420. // Horizontal flipping is used to save space,
  421. //  thus NNNNF2F5 defines a mirrored patch.
  422. // Some sprites will only have one picture used
  423. // for all views: NNNNF0
  424. //
  425. typedef struct
  426. {
  427.     // If false use 0 for any position.
  428.     // Note: as eight entries are available,
  429.     //  we might as well in